//
//  PlayIn.h
//  PlayIN
//
//  Created by playin on 2019/2/5.
//  Copyright © 2019 playin. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum : NSInteger
{
    PIErrorNone = 0,        // no error
    PIErrorInner = 1,       // inner error
    PIErrorParams = 2,      // sdk_key or adid invalid
    PIErrorNetwork = 3,     // network error
    PIErrorRegister = 4,    // register stream fail
    PIErrorResource = 5,    // no available playin resource
    PIErrorDuplicate = 6,   // duplicate play
    PIErrorUnknown = -1,    // unknown error
} PIError;

@protocol PlayInDelegate <NSObject>

// the following callbacks are dispatched in main_queue and be calling during the playing
- (void)onPlayInStart:(int)duration;
- (void)onPlayInStop;
- (void)onPlayInError:(NSDictionary *)error;

@end

@interface PlayIn : NSObject

@property (nonatomic, strong) UIView *playInView;

@property (nonatomic, weak) id<PlayInDelegate> delegate;

+ (instancetype)sharedInstance;

- (void)startPlayWithUserId:(NSString *)userId
                   userType:(NSString *)userType;

- (void)stopPlay;

- (id)init __attribute__((unavailable("Use sharedInstance instead of alloc-init pattern.")));
+ (instancetype)initialize NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

@end
